package main

import "fmt"

func main() {

	// iota 常量自动生成器， 每个一行， 自动累加1
	// iota 给常量赋值使用
	const (
		a = iota // 0
		b = iota // 1
		c = iota // 2
	)

	fmt.Printf("a = %d, b = %d, c = %d\n", a, b, c)

	// iota遇到const 重置为0
	const d = iota // 0

	fmt.Println("d = ", d)

	// 4 可以只写一个iota
	const (
		a1 = iota // 0
		b1        // 1
		c1        // 2
	)
	fmt.Printf("a = %d, b = %d, c = %d\n", a1, b1, c1)

	// 5 如果是同一行，值都一样
	const (
		i          = iota             // 0
		j1, j2, j3 = iota, iota, iota // 1
		k          = iota             // 2
	)
	fmt.Printf("i = %d, j1 = %d, j2 = %d,  j3 = %d, k = %d,\n", i, j1, j2, j3, k)

	// 中间赋值 不影响iota自增
	const (
		aa = iota //0
		bb        //1
		cc        //2
		dd = "ha" //独立值，iota += 1
		ee        //"ha"   iota += 1
		ff = 100  //iota +=1
		gg        //100  iota +=1
		hh = iota //7,恢复计数
		ii        //8
	)
	fmt.Println(aa, bb, cc, dd, ee, ff, gg, hh, ii)

	const (
		xx1 = iota + 10
		xx2 = iota + 10
		xx3 = iota + 10
	)
	fmt.Println(xx1, xx2, xx3)
}
